home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.3 (Developer)…68k, x86, SPARC, PA-RISC] / NeXTSTEP 3.3 Dev Intel.iso / NextDeveloper / Headers / bsd / dev / m68k / busvar.h < prev    next >
Text File  |  1995-02-14  |  6KB  |  170 lines

  1. /* 
  2.  * Copyright (c) 1987 Next, Inc.
  3.  *
  4.  * HISTORY
  5.  * 22-May-91  Gregg Kellogg (gk) at NeXT
  6.  *    Split out public interface.
  7.  *
  8.  * 11-Jul-90  Gregg Kellogg (gk) at NeXT
  9.  *    Changed bc_tab from a struct buf * to a queue_head_t.
  10.  *
  11.  * 04-Mar-87  John Seamons (jks) at NeXT
  12.  *    Ported to NeXT.
  13.  */ 
  14.  
  15. #ifndef    _M68K_DEV_BUSVAR_
  16. #define _M68K_DEV_BUSVAR_
  17.  
  18. #import <kernserv/queue.h>
  19. #import <sys/callout.h>
  20. #import <bsd/dev/busvar.h>
  21.  
  22. /*
  23.  * This file contains definitions related to the kernel structures
  24.  * for dealing with the device bus.
  25.  *
  26.  * Each bus has a bus_hd structure.
  27.  * Each bus controller which is not a device has a bus_ctrl structure.
  28.  * Each bus device has a bus_device structure.
  29.  */
  30.  
  31. #ifndef ASSEMBLER
  32. /*
  33.  * Per-bus structure.
  34.  *
  35.  * At boot time we determine the devices attached to the bus.
  36.  * Additional devices may be added at a later time via the
  37.  * loadable device driver mechanism.
  38.  *
  39.  * During normal operation, resources are allocated and returned
  40.  * to the structures here.
  41.  * 
  42.  * When bus resources are needed and not available, or if a device
  43.  * which can tolerate no other bus activity gets on the bus,
  44.  * then device drivers may have to wait to get to the bus and are
  45.  * queued here.
  46.  */
  47. struct    bus_hd {
  48.     struct    bus_device *bh_actf;    /* head of queue to transfer */
  49.     struct    bus_device *bh_actl;    /* tail of queue to transfer */
  50.     short    bh_users;        /* transient use count */
  51.     short    bh_xclu;        /* exclusive use of bus */
  52. };
  53.  
  54. /*
  55.  * Per-controller structure.
  56.  * (E.g. one for each disk and tape controller)
  57.  *
  58.  * If a controller has devices attached, then there are
  59.  * cross-referenced bus_drive structures.
  60.  * This structure is the one which is queued in bus resource wait,
  61.  * and saves the information about bus resources which are used.
  62.  * The queue of devices waiting to transfer is also attached here.
  63.  */
  64. struct bus_ctrl {
  65.     /* start of fields initialized by ioconf.c */
  66.     struct    bus_driver *bc_driver;
  67.     short    bc_ctrl;    /* controller index in driver */
  68.     short    bc_ipl;        /* interrupt level */
  69.     void    *bc_addr;    /* address of device in I/O space */
  70.     /* end of fields initialized by ioconf.c */
  71.  
  72.     struct    bus_hd *bc_hd;    /* bus this controller is on */
  73.     struct    bus_device *bc_device;
  74. /* the driver saves the prototype command here for use in its go routine */
  75.     int    bc_cmd;        /* communication to go() */
  76.     queue_head_t bc_tab;    /* queue of devices for this controller */
  77.     int    bc_active;    /* Bus controller is active */
  78.     short    bc_alive;    /* controller exists */
  79. };
  80.  
  81. /*
  82.  * Per ``device'' structure.
  83.  * (A controller has devices -- everything else is a ``device''.)
  84.  *
  85.  * If a controller has many drives attached, then there will
  86.  * be several bus_device structures associated with a single bus_ctrl
  87.  * structure.
  88.  *
  89.  * This structure contains all the information necessary
  90.  * to run a bus device.  It also contains information
  91.  * for slaves of bus controllers as to which device on the slave
  92.  * this is.  A flags field here can also be given in the system specification
  93.  * and is used to tell which serial lines are hard wired or other device
  94.  * specific parameters.
  95.  */
  96. struct bus_device {
  97.     /* start of fields initialized by ioconf.c */
  98.     struct    bus_driver *bd_driver;
  99.     short    bd_unit;    /* unit number on the system */
  100.     short    bd_ctrl;    /* mass ctrl number; -1 if none */
  101.     short    bd_slave;    /* slave on controller */
  102.     char    bd_ipl;        /* interrupt level of device */
  103.     short    bd_dk;        /* if init 1 set to number for iostat */
  104.     int    bd_flags;    /* parameter from system specification */
  105.     void    *bd_addr;    /* address of device in I/O space */
  106.     char    *bd_name;    /* device name */
  107.     /* end of fields initialized by ioconf.c */
  108.  
  109.     short    bd_alive;    /* device exists */
  110.     short    bd_type;    /* driver specific type information */
  111. /* this is the forward link in a list of devices on a controller */
  112.     struct    bus_device *bd_forw;
  113. /* if the device is connected to a controller, this is the controller */
  114.     struct    bus_ctrl *bd_bc;
  115.     struct    bus_hd *bd_hd;
  116. };
  117.  
  118. /*
  119.  * Per-driver structure.
  120.  *
  121.  * Each device driver defines entries for a set of routines
  122.  * as well as an array of types which are acceptable to it.
  123.  * These are used at boot time by the configuration program.
  124.  */
  125. struct bus_driver {
  126.     int    (*br_probe)();        /* see if a driver is really there */
  127.     int    (*br_slave)();        /* see if a slave is there */
  128.     int    (*br_attach)();        /* setup driver for a slave */
  129.     int    (*br_go)();        /* start transfer */
  130.     int    (*br_done)();        /* complete transfer */
  131.     int    (*br_intr)();        /* service interrupt */
  132.     int    (*br_init)();        /* initialize device */
  133.     int    br_size;        /* device register size */
  134.     char    *br_dname;        /* name of a device */
  135.     struct    bus_device **br_dinfo;    /* backpointers to bus_dinit structs */
  136.     char    *br_cname;        /* name of a controller */
  137.     struct    bus_ctrl **br_cinfo;    /* backpointers to bus_cinit structs */
  138.     short    br_flags;        /* driver flags */
  139. #define    BUS_XCLU    0x0001        /* want exclusive use of bus */
  140. #define    BUS_SCSI    0x0002        /* this is SCSI controller */
  141. };
  142. #endif    !ASSEMBLER
  143.  
  144. #define    BUS_CANTWAIT    0x01        /* don't block me */
  145.  
  146. #ifndef ASSEMBLER
  147. #ifdef KERNEL
  148. /*
  149.  * Bus related kernel variables
  150.  */
  151. extern struct    bus_hd bus_hd;
  152.  
  153. /*
  154.  * bus_cinit and bus_dinit initialize the mass storage controller
  155.  * and ordinary device tables specifying possible devices.
  156.  */
  157. extern    struct    bus_ctrl bus_cinit[];
  158. extern    struct    bus_device bus_dinit[];
  159.  
  160. /*
  161.  * Support for polled interrupts on the bus.
  162.  */
  163. #define    NPOLL    8            /* max number of polling routines */
  164. extern func poll_intr[];        /* polled routines to call */
  165. #define    POLLED_IPL    5        /* polling ipl */
  166. #endif KERNEL
  167.  
  168. #endif !ASSEMBLER
  169. #endif _M68K_DEV_BUSVAR_
  170.